********************************************************************************
********************************************************************************
** Robustness analysis 10
** Heterogeneity in regard to primary school exam scores
********************************************************************************
********************************************************************************

** Load data
use "$dataraw_path\data_ftna_publication.dta", clear


gen gpa_psle_core_sq = gpa_psle_core^2

egen gpa_psle_core_int = group(gpa_psle_core)

eststo rob11_1: areg gpa_ftna_core_sd 1.private 1.private#c.gpa_psle_core ///
	female uncommon_name peers_score_core_sd peers_fail_share peers_as_share ///
	gpa_psle_other_sd, ///
	cl(school_id) a(group_id)
	
eststo rob11_2: areg gpa_ftna_core_sd 1.private 1.private#c.gpa_psle_core ///
	1.private#c.gpa_psle_core_sq ///
	female uncommon_name peers_score_core_sd peers_fail_share peers_as_share ///
	gpa_psle_other_sd, ///
	cl(school_id) a(group_id)

eststo rob11_3: areg gpa_ftna_core_sd private##ib7.gpa_psle_core_int female ///
	uncommon_name peers_score_core_sd peers_fail_share peers_as_share ///
	gpa_psle_other_sd, ///
	cl(school_id) a(group_id)

drop gpa_psle_core_sq gpa_psle_core_int


* Output
esttab rob11_* using "$out_path\tableb7.tex", replace se ///
stats(N r2, fmt(%12.3gc) labels("\(N\)" "\(R^2\)")) compress nomtitles ///
starlevels("" 0.01) substitute(\_ _) b(3) ///
/*KEEP*/k(1.private 1.private#c.gpa_psle_core 1.private#c.gpa_psle_core_sq ///
1.private#3.gpa_psle_core_int 1.private#4.gpa_psle_core_int ///
1.private#5.gpa_psle_core_int 1.private#6.gpa_psle_core_int ///
1.private#8.gpa_psle_core_int 1.private#9.gpa_psle_core_int ///
1.private#10.gpa_psle_core_int 1.private#11.gpa_psle_core_int ///
1.private#12.gpa_psle_core_int 1.private#13.gpa_psle_core_int) ///
/*ORDER*/o(1.private 1.private#c.gpa_psle_core 1.private#c.gpa_psle_core_sq ///
1.private#3.gpa_psle_core_int 1.private#4.gpa_psle_core_int ///
1.private#5.gpa_psle_core_int 1.private#6.gpa_psle_core_int ///
1.private#8.gpa_psle_core_int 1.private#9.gpa_psle_core_int ///
1.private#10.gpa_psle_core_int 1.private#11.gpa_psle_core_int ///
1.private#12.gpa_psle_core_int 1.private#13.gpa_psle_core_int) ///
/*LABELS*/varl(1.private "\$Private_s$" ///
1.private#c.gpa_psle_core "\$Private\times\textit{GPA PSLE (continuous)}$" ///
1.private#c.gpa_psle_core_sq "\$Private\times\textit{GPA PSLE squared (continuous)}$" ///
1.private#3.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 0.67}$" ///
1.private#4.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 1 = 'D'}$" ///
1.private#5.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 1.33}$" ///
1.private#6.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 1.67}$" ///
1.private#8.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 2.33}$" ///
1.private#9.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 2.67}$" ///
1.private#10.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 3 = 'B'}$" ///
1.private#11.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 3.33}$" ///
1.private#12.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 3.67}$" ///
1.private#13.gpa_psle_core_int "\$Private\times\textit{GPA PSLE = 4 = 'A'}$")
